package com.baizhan.springBootDemo1.controller;

import com.baizhan.springBootDemo1.domain.Grade;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
/*通过@ConfigurationProperties(prefifix="对象")
可以将配置文件中的配置自动与实体进行映射，
这样可以将yml文件中配置的对象属性直接映射到Bean当中。*/
@Controller
@ConfigurationProperties(prefix = "user")
public class YmlController2 {
    private int id;
    private String username;
    private List<String> address;
    private List<Grade> grades;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public List<String> getAddress() {
        return address;
    }

    public void setAddress(List<String> address) {
        this.address = address;
    }

    public List<Grade> getGrades() {
        return grades;
    }

    public void setGrades(List<Grade> grades) {
        this.grades = grades;
    }

    @RequestMapping("/yml2")
    @ResponseBody
    public String yml2(){
        System.out.println(id);
        System.out.println(username);
        System.out.println(address);
        System.out.println(grades);
        return "hello springBoot";
    }
}
